+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- import "module" assert {}
+ import "module" with {}
```
- Fix an issue where JSON formatter does not respect `lineWidth` for arrays [#4351](https://github.com/rome/tools/issues/4351)
### Linter

#### Other changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ expression: content
{
"formatter": {
"ignore": [
"test1.js", "./test2.js", "./test3/**/*", "/test4/**/*", "test5/**/*",
"**/test6/*.js", "*.test7.js"
"test1.js",
"./test2.js",
"./test3/**/*",
"/test4/**/*",
"test5/**/*",
"**/test6/*.js",
"*.test7.js"
]
}
}
Expand Down
11 changes: 2 additions & 9 deletions crates/rome_json_formatter/src/json/lists/array_element_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ pub(crate) fn can_concisely_print_array_list(list: &JsonArrayElementList) -> boo
return false;
}

list.iter().all(|node| {
matches!(
node,
Ok(AnyJsonValue::JsonStringValue(_)
| AnyJsonValue::JsonBooleanValue(_)
| AnyJsonValue::JsonNullValue(_)
| AnyJsonValue::JsonNumberValue(_))
)
})
list.iter()
.all(|node| matches!(node, Ok(AnyJsonValue::JsonNumberValue(_))))
}
19 changes: 13 additions & 6 deletions crates/rome_json_formatter/tests/quick_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ mod language {
fn quick_test() {
let src = r#"
{
"a": 5,
"b": [1, 2, 3, 4],
"c": null,
"d": true,
"e": false
}
"enabled": true,
"formatWithErrors": false,
"indentSize": 2,
"indentStyle": "space",
"lineWidth": 80,
"ignore": [
"**/cache/**",
"**/dist/**",
"./packages/laravel/**/*",
"./packages/presets/templates/**/*",
"./sandboxes/**/*"
]
}
"#;
let parse = parse_json(src);
let options = JsonFormatOptions::default();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
123231321, 123213213, 12312321, 12321123211232112321, 12321321, 1232132112321321123213211232132112321321
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
source: crates/rome_formatter_test/src/snapshot_builder.rs
info: json/array/fill_layout.json
---

# Input

```json
[
123231321, 123213213, 12312321, 12321123211232112321, 12321321, 1232132112321321123213211232132112321321
]

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Line width: 80
-----

```json
[
123231321, 123213213, 12312321, 12321123211232112321, 12321321,
1232132112321321123213211232132112321321
]
```


Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ Line width: 80
```json
{
"fillLayout": [
"aaaa", "bbb", "cc",
"aaaa",
"bbb",
"cc",

true, false, 111, 44, null
true,
false,
111,
44,
null
],
"oneLineLayout": [
"aaa",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ Line width: 80
{
"array": [
"Longggggggggggggggggggggggggggggggggggg",
9999999999999999999999999999999999999, 1111112222222223333344444444, true
9999999999999999999999999999999999999,
1111112222222223333344444444,
true
],
"indented": [
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ Line width: 80
"long": [
11111,
[
"nestedddddddddddd", 22222222222222222222222222, true,
5555555555555555555555, "indenteddddddddddddddddddddddddddddd"
"nestedddddddddddd",
22222222222222222222222222,
true,
5555555555555555555555,
"indenteddddddddddddddddddddddddddddd"
],
"Element"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"boolean": [
true, true, true, true, true, true, true, true, false, false, false, true, false, false
],
"strings": [
"longlongstringlonglongstring", "12312321", "longlongstringlonglongstring"
],
"null": [
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
source: crates/rome_formatter_test/src/snapshot_builder.rs
info: json/array/one_per_line_layout.json
---

# Input

```json
{
"boolean": [
true, true, true, true, true, true, true, true, false, false, false, true, false, false
],
"strings": [
"longlongstringlonglongstring", "12312321", "longlongstringlonglongstring"
],
"null": [
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null
]
}

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Line width: 80
-----

```json
{
"boolean": [
true,
true,
true,
true,
true,
true,
true,
true,
false,
false,
false,
true,
false,
false
],
"strings": [
"longlongstringlonglongstring",
"12312321",
"longlongstringlonglongstring"
],
"null": [
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
}
```


点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载