Skip to content

formatter: Different behavior when running from CLI vs IDE format on save #140

@abstractalgo

Description

@abstractalgo

Running yarn oxfmt in CLI behaves differently from running formatting via IDE.

In the video below you can see:

  • "Format document via..." > "Oxc" changes the file (✅ correct behavior)
  • ...but running yarn oxfmt from terminal doesn't make changes (❌ incorrect behavior)

I'm reporting this here instead of oxc-vscode because in this case, the run via CLI is incorrect, since "trailingComma" config is "all" by default, and yet the CLI doesn't format the file.

oxfmt.mp4

I don't have a simple repro for now.


Setup:

"oxfmt": "^0.37.0"
"oxc.oxc-vscode": "1.49.1"
.oxfmtrc.json:
{
  "$schema": "./node_modules/oxfmt/configuration_schema.json",
  "bracketSpacing": true,
  "singleQuote": true,
  "jsxSingleQuote": true,
  "printWidth": 80,
  "ignorePatterns": [".yarn", ".github/reports", ".serena"],
  "sortImports": {
    "newlinesBetween": true,
    "customGroups": [
      {
        "groupName": "primer",
        "elementNamePattern": ["@primer-io/**"]
      },
      {
        "groupName": "tsconfig-paths",
        "elementNamePattern": ["MODULES/**", "UTILS/**", "LEGACY/**", "SRC/**"]
      }
    ],
    "groups": [
      ["builtin", "external", "primer"],
      ["tsconfig-paths"],
      [
        "type-internal",
        "value-internal",
        "type-sibling",
        "value-sibling",
        "value-parent",
        "type-parent",
        "type-index",
        "value-index",
        "unknown"
      ],
      ["style"]
    ]
  }
}
.vscode/settings.json:
{
  "js/ts.tsdk.path": "./node_modules/typescript/lib",
  "js/ts.updateImportsOnFileMove.enabled": "always",
  "[javascript][typescript][typescriptreact][json][html][javascriptreact][css][jsonc]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "oxc.oxc-vscode"
  },
  "editor.codeActionsOnSave": {
    "source.fixAll.oxc": "explicit",
    "source.removeUnusedImports": "explicit"
  },
  // "oxc.path.node": "$HOME/.nvm/versions/node/v24.11.0/bin/node",
  "githubPullRequests.commentExpandState": "collapseAll",
  "prettier.enable": false,
  "eslint.enable": false,
  "oxc.enable": true,
  "oxc.typeAware": true
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions