Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Formatter propose change that brokes parse with comment and async function #1406

Closed
1 task done
witem opened this issue Jan 2, 2024 · 2 comments · Fixed by #1500
Closed
1 task done

📝 Formatter propose change that brokes parse with comment and async function #1406

witem opened this issue Jan 2, 2024 · 2 comments · Fixed by #1500
Labels
A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@witem
Copy link

witem commented Jan 2, 2024

Environment information

CLI:
  Version:                      1.4.1
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "screen-256color"
  JS_RUNTIME_VERSION:           "v18.16.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "yarn/3.2.3"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

Configuration

{
  "$schema": "https://biomejs.dev/schemas/1.4.1/schema.json",
  "organizeImports": {
    "enabled": true
  },
  "files": {
    "ignore": ["*.md", "__*.ts", "node_modules/**/*", "dist/**/*"]
  },
  "formatter": {
    "indentStyle": "space",
    "indentWidth": 2,
    "lineWidth": 100,
    "ignore": []
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "style": {
        "noParameterAssign": "warn"
      },
      "suspicious": {
        "noExplicitAny": "warn",
        "noConfusingVoidType": "warn",
        "noAssignInExpressions": "warn",
        "noMisrefactoredShorthandAssign": "error"
      },
      "complexity": {
        "noForEach": "off",
        "noStaticOnlyClass": "warn",
        "noExcessiveCognitiveComplexity": {
          "level": "error",
          "options": {
            "maxAllowedComplexity": 20
          }
        }
      },
      "correctness": {
        "noVoidTypeReturn": "warn"
      }
    }
  },
  "javascript": {
    "parser": {
      "unsafeParameterDecoratorsEnabled": true
    },
    "formatter": {
      "quoteStyle": "single",
      "quoteProperties": "asNeeded",
      "trailingComma": "all",
      "semicolons": "always"
    }
  }
}

Playground link

https://biomejs.dev/playground/?code=QABJAG4AagBlAGMAdABhAGIAbABlACgAKQAKAGUAeABwAG8AcgB0ACAAYwBsAGEAcwBzACAATABCAG8AbwBrACAAZQB4AHQAZQBuAGQAcwAgAEkAbgBkAGUAeABlAHIAQQBiAHMAdAByAGEAYwB0ACAAewAKACAAIABAAHMAbwBtAGUARABlAGMAbwByAGEAdABvAHIAKAB7AAoAIAAgACAAIABiAGEAdABjAGgAOgAgAHQAcgB1AGUALAAKACAAIAB9ACkACgAgACAALwAvACAAYgBpAG8AbQBlAC0AaQBnAG4AbwByAGUAIABsAGkAbgB0AC8AYwBvAG0AcABsAGUAeABpAHQAeQAvAG4AbwBFAHgAYwBlAHMAcwBpAHYAZQBDAG8AZwBuAGkAdABpAHYAZQBDAG8AbQBwAGwAZQB4AGkAdAB5ADoAIABuAGUAZQBkACAAdABvACAAcgBlAGYAYQBjAHQAbwByAAoAIAAgAGEAcwB5AG4AYwAgAGgAYQBuAGQAbABlAEwAQgBvAG8AawAoAGUAdgBlAG4AdABzADoAIAB1AG4AawBuAG8AdwBuAFsAXQApACAAewAKACAAIAAgACAAYwBvAG4AcwBvAGwAZQAuAGwAbwBnACgAZQB2AGUAbgB0AHMAKQA7AAoAIAAgAH0ACgB9AA%3D%3D

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@witem
Copy link
Author

witem commented Jan 2, 2024

It brake code, putting a comment between async and the function name.
image
image

@faultyserver faultyserver added A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug labels Jan 2, 2024
@faultyserver
Copy link
Contributor

The error here is that async cannot have a newline after it before the name of the function it applies to, otherwise the name gets interpreted as a plain identifier and not a keyword (even in strict mode, weirdly).

The fix for this issue is to match the output that Prettier has and preserve the comment above the async token, rather than moving it to between the token and the name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants