Skip to content

Commit a6d4dd3

Browse files
committed
Add braceStyle option with same-line (default) and next-line choices.
1 parent 2e93556 commit a6d4dd3

20 files changed

Lines changed: 80 additions & 77 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repos:
1212
- id: end-of-file-fixer
1313
exclude: "package-lock\\.json|^\\.idea/"
1414
- id: trailing-whitespace
15-
exclude: "package-lock\\.json|^\\.idea/"
15+
exclude: "package-lock\\.json|^\\.idea/|prettier-ignore.*_output\\.java$"
1616
- id: check-added-large-files
1717
args: ["--maxkb=1000"]
1818
- id: check-case-conflict
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"braceStyle": "next-line"
3+
}

packages/prettier-plugin-java/test/unit-test/binary_expressions/binary_expressions-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
66

77
describe("prettier-java", () => {
88
testSampleWithOptions({
9-
testFolder: path.resolve(__dirname, "operator-position-start")
9+
testFolder: path.resolve(__dirname, "operator-position-start"),
1010
});
1111

1212
testSampleWithOptions({
13-
testFolder: path.resolve(__dirname, "operator-position-end")
13+
testFolder: path.resolve(__dirname, "operator-position-end"),
1414
});
1515
testSample(path.resolve(__dirname, "operator-position-end"));
1616
});

packages/prettier-plugin-java/test/unit-test/comments/comments-spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ describe("prettier-java", () => {
1111
testSample(path.resolve(__dirname, "./interface"));
1212
testSample(path.resolve(__dirname, "./package"));
1313
testSample(
14-
path.resolve(__dirname, "./comments-blocks-and-statements/complex")
14+
path.resolve(__dirname, "./comments-blocks-and-statements/complex"),
1515
);
1616
testSample(
17-
path.resolve(__dirname, "./comments-blocks-and-statements/if-statement")
17+
path.resolve(__dirname, "./comments-blocks-and-statements/if-statement"),
1818
);
1919
testSample(
2020
path.resolve(
2121
__dirname,
22-
"./comments-blocks-and-statements/labeled-statement"
23-
)
22+
"./comments-blocks-and-statements/labeled-statement",
23+
),
2424
);
2525
testSample(path.resolve(__dirname, "./comments-only"));
2626
testSample(path.resolve(__dirname, "./bug-fixes"));

packages/prettier-plugin-java/test/unit-test/else-if/else-if-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
66

77
describe("else-if formatting", () => {
88
testSampleWithOptions({
9-
testFolder: __dirname
9+
testFolder: __dirname,
1010
});
1111
});

packages/prettier-plugin-java/test/unit-test/require-pragma/require-pragma-spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ describe("prettier-java: require-pragma option", () => {
88
[
99
path.resolve(__dirname, "./format-pragma"),
1010
path.resolve(__dirname, "./prettier-pragma"),
11-
path.resolve(__dirname, "./invalid-pragma")
12-
].forEach(testFolder => {
11+
path.resolve(__dirname, "./invalid-pragma"),
12+
].forEach((testFolder) => {
1313
testSampleWithOptions({
14-
testFolder
14+
testFolder,
1515
});
1616
});
1717
});

packages/prettier-plugin-java/test/unit-test/snippets/arrays/array-initializer.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ describe("Arrays Initializer", () => {
55
expectSnippetToBeFormatted({
66
snippet: "{ }",
77
expectedOutput: "{}",
8-
entryPoint: "arrayInitializer"
8+
entryPoint: "arrayInitializer",
99
});
1010
});
1111

1212
it("can format a arrayInitializer", () => {
1313
expectSnippetToBeFormatted({
1414
snippet: "{alpha}",
1515
expectedOutput: "{ alpha }",
16-
entryPoint: "arrayInitializer"
16+
entryPoint: "arrayInitializer",
1717
});
1818
});
1919

@@ -22,14 +22,14 @@ describe("Arrays Initializer", () => {
2222
expectSnippetToBeFormatted({
2323
snippet: "{alpha,}",
2424
expectedOutput: "{ alpha }",
25-
entryPoint: "arrayInitializer"
25+
entryPoint: "arrayInitializer",
2626
});
2727
});
2828

2929
it("should remove extra comma in arrayInitializer by default", () => {
3030
const snippet = "{oneVeryLongArrayValue,}";
3131
const prettierOptions = {
32-
printWidth: 15
32+
printWidth: 15,
3333
};
3434
// prettier-ignore
3535
const expectedOutput =
@@ -41,7 +41,7 @@ describe("Arrays Initializer", () => {
4141
snippet,
4242
expectedOutput,
4343
entryPoint: "arrayInitializer",
44-
prettierOptions
44+
prettierOptions,
4545
});
4646
});
4747

@@ -51,8 +51,8 @@ describe("Arrays Initializer", () => {
5151
expectedOutput: "{ oneVeryLongArrayValue }",
5252
entryPoint: "arrayInitializer",
5353
prettierOptions: {
54-
trailingComma: "all"
55-
}
54+
trailingComma: "all",
55+
},
5656
});
5757
});
5858

@@ -62,8 +62,8 @@ describe("Arrays Initializer", () => {
6262
expectedOutput: "{ oneVeryLongArrayValue }",
6363
entryPoint: "arrayInitializer",
6464
prettierOptions: {
65-
trailingComma: "all"
66-
}
65+
trailingComma: "all",
66+
},
6767
});
6868
});
6969

@@ -80,8 +80,8 @@ describe("Arrays Initializer", () => {
8080
entryPoint: "arrayInitializer",
8181
prettierOptions: {
8282
printWidth: 15,
83-
trailingComma: "all"
84-
}
83+
trailingComma: "all",
84+
},
8585
});
8686
});
8787

@@ -98,8 +98,8 @@ describe("Arrays Initializer", () => {
9898
entryPoint: "arrayInitializer",
9999
prettierOptions: {
100100
printWidth: 15,
101-
trailingComma: "all"
102-
}
101+
trailingComma: "all",
102+
},
103103
});
104104
});
105105
});

packages/prettier-plugin-java/test/unit-test/snippets/arrays/variable-initializer-list.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ describe("VariableInitializerList", () => {
55
expectSnippetToBeFormatted({
66
snippet: "alpha ",
77
expectedOutput: "alpha",
8-
entryPoint: "variableInitializerList"
8+
entryPoint: "variableInitializerList",
99
});
1010
});
1111

1212
it("format variableInitializerList with multiple variableInitializer", () => {
1313
expectSnippetToBeFormatted({
1414
snippet: "alpha,beta, gamma",
1515
expectedOutput: "alpha,\nbeta,\ngamma",
16-
entryPoint: "variableInitializerList"
16+
entryPoint: "variableInitializerList",
1717
});
1818
});
1919
});

packages/prettier-plugin-java/test/unit-test/snippets/blocks-and-statements/switch.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("Switches", () => {
2222
expectSnippetToBeFormatted({
2323
snippet,
2424
expectedOutput,
25-
entryPoint: "switchStatement"
25+
entryPoint: "switchStatement",
2626
});
2727
});
2828
});

packages/prettier-plugin-java/test/unit-test/snippets/classes/class-body.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe("Class Body", () => {
55
expectSnippetToBeFormatted({
66
snippet: "{ }",
77
expectedOutput: "{}",
8-
entryPoint: "classBody"
8+
entryPoint: "classBody",
99
});
1010
});
1111

@@ -19,7 +19,7 @@ describe("Class Body", () => {
1919
expectSnippetToBeFormatted({
2020
snippet: "{int i;}",
2121
expectedOutput,
22-
entryPoint: "classBody"
22+
entryPoint: "classBody",
2323
});
2424
});
2525

@@ -45,7 +45,7 @@ describe("Class Body", () => {
4545
expectSnippetToBeFormatted({
4646
snippet,
4747
expectedOutput,
48-
entryPoint: "classBody"
48+
entryPoint: "classBody",
4949
});
5050
});
5151

@@ -71,7 +71,7 @@ describe("Class Body", () => {
7171
expectSnippetToBeFormatted({
7272
snippet,
7373
expectedOutput,
74-
entryPoint: "classBody"
74+
entryPoint: "classBody",
7575
});
7676
});
7777

@@ -101,7 +101,7 @@ describe("Class Body", () => {
101101
expectSnippetToBeFormatted({
102102
snippet,
103103
expectedOutput,
104-
entryPoint: "classBody"
104+
entryPoint: "classBody",
105105
});
106106
});
107107

@@ -110,7 +110,7 @@ describe("Class Body", () => {
110110
expectSnippetToBeFormatted({
111111
snippet: "{;;}",
112112
expectedOutput: "{}",
113-
entryPoint: "classBody"
113+
entryPoint: "classBody",
114114
});
115115
});
116116

@@ -139,7 +139,7 @@ describe("Class Body", () => {
139139
expectSnippetToBeFormatted({
140140
snippet,
141141
expectedOutput,
142-
entryPoint: "classBody"
142+
entryPoint: "classBody",
143143
});
144144
});
145145

@@ -170,15 +170,15 @@ describe("Class Body", () => {
170170
expectSnippetToBeFormatted({
171171
snippet,
172172
expectedOutput,
173-
entryPoint: "classBody"
173+
entryPoint: "classBody",
174174
});
175175
});
176176

177177
it("should print comments attached to empty statement where only empty statements", () => {
178178
expectSnippetToBeFormatted({
179179
snippet: "{;/* TODO */;}",
180180
expectedOutput: "{\n" + " /* TODO */\n" + "}",
181-
entryPoint: "classBody"
181+
entryPoint: "classBody",
182182
});
183183
});
184184

@@ -208,7 +208,7 @@ describe("Class Body", () => {
208208
expectSnippetToBeFormatted({
209209
snippet,
210210
expectedOutput,
211-
entryPoint: "classBody"
211+
entryPoint: "classBody",
212212
});
213213
});
214214
});

0 commit comments

Comments
 (0)