Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

🐛 JSON formatter does not respect lineWidth for arrays #4351

Closed
1 task done
jrson83 opened this issue Apr 6, 2023 · 0 comments · Fixed by #4367
Closed
1 task done

🐛 JSON formatter does not respect lineWidth for arrays #4351

jrson83 opened this issue Apr 6, 2023 · 0 comments · Fixed by #4367
Assignees
Labels
A-Formatter Area: formatter S-Bug: confirmed Status: report has been confirmed as a valid bug

Comments

@jrson83
Copy link

jrson83 commented Apr 6, 2023

Environment information

CLI:
  Version:                      12.0.0
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  ROME_LOG_DIR:                 unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v18.14.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/8.1.1"

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

Workspace:
  Open Documents:               0

What happened?

The JSON formatter does not respect lineWidth for arrays. In the example see the ignore array.

When formatting a json file migrated from prettier:

{
  "$schema": "./node_modules/rome/configuration_schema.json",
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentSize": 2,
    "indentStyle": "space",
    "lineWidth": 80,
    "ignore": [
      "**/cache/**",
      "**/dist/**",
      "./packages/laravel/**/*",
      "./packages/presets/templates/**/*",
      "./sandboxes/**/*"
    ]
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "quoteProperties": "asNeeded",
      "semicolons": "asNeeded",
      "trailingComma": "es5"
    }
  }
}

Rome formatter output:

{
  "$schema": "./node_modules/rome/configuration_schema.json",
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentSize": 2,
    "indentStyle": "space",
    "lineWidth": 80,
    "ignore": [
      "**/cache/**", "**/dist/**", "./packages/laravel/**/*",
      "./packages/presets/templates/**/*", "./sandboxes/**/*"
    ]
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "quoteProperties": "asNeeded",
      "semicolons": "asNeeded",
      "trailingComma": "es5"
    }
  }
}

Expected result

The result should be the same as the prettier result from the playground:

{
  "$schema": "./node_modules/rome/configuration_schema.json",
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentSize": 2,
    "indentStyle": "space",
    "lineWidth": 80,
    "ignore": [
      "**/cache/**",
      "**/dist/**",
      "./packages/laravel/**/*",
      "./packages/presets/templates/**/*",
      "./sandboxes/**/*"
    ]
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "quoteProperties": "asNeeded",
      "semicolons": "asNeeded",
      "trailingComma": "es5"
    }
  }
}

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@jrson83 jrson83 added the S-To triage Status: user report of a possible bug that needs to be triaged label Apr 6, 2023
@ematipico ematipico added S-Bug: confirmed Status: report has been confirmed as a valid bug A-Formatter Area: formatter and removed S-To triage Status: user report of a possible bug that needs to be triaged labels Apr 6, 2023
@denbezrukov denbezrukov self-assigned this Apr 11, 2023
denbezrukov added a commit to denbezrukov/tools that referenced this issue Apr 11, 2023
denbezrukov added a commit to denbezrukov/tools that referenced this issue Apr 11, 2023
denbezrukov added a commit that referenced this issue Apr 11, 2023
…or arrays #4351 (#4367)

fix(rome_json_formatter): JSON formatter does not respect lineWidth for arrays #4351
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Formatter Area: formatter S-Bug: confirmed Status: report has been confirmed as a valid bug
Projects
None yet
3 participants