diff --git a/docs/rules/brace-style.md b/docs/rules/brace-style.md index 37098b1cd49..dce2d96499c 100644 --- a/docs/rules/brace-style.md +++ b/docs/rules/brace-style.md @@ -129,6 +129,27 @@ if (foo) { bar(); } if (foo) { bar(); } else { baz(); } try { somethingRisky(); } catch(e) { handleError(); } + +if (foo) { baz(); } else { + boom(); +} + +if (foo) { baz(); } else if (bar) { + boom(); +} + +if (foo) { baz(); } else +if (bar) { + boom(); +} + +if (foo) { baz); } else if (bar) { + boom(); +} + +try { somethingRisky(); } catch(e) { + handleError(); +} ``` ### stroustrup diff --git a/tests/lib/rules/brace-style.js b/tests/lib/rules/brace-style.js index 4444863b65d..70211608bb8 100644 --- a/tests/lib/rules/brace-style.js +++ b/tests/lib/rules/brace-style.js @@ -82,6 +82,22 @@ ruleTester.run("brace-style", rule, { { code: "if (foo) {}\nelse {}", options: ["allman", { allowSingleLine: true }] }, { code: "try { bar(); }\ncatch (e) { baz(); }", options: ["allman", { allowSingleLine: true }] }, { code: "var foo = () => { return; }", options: ["allman", { allowSingleLine: true }], parserOptions: { ecmaVersion: 6 } }, + { + code: "if (foo) { baz(); } else {\n boom();\n}", + options: ["1tbs", { allowSingleLine: true }] + }, + { + code: "if (foo) { baz(); } else if (bar) {\n boom();\n}", + options: ["1tbs", { allowSingleLine: true }] + }, + { + code: "if (foo) { baz(); } else\nif (bar) {\n boom();\n}", + options: ["1tbs", { allowSingleLine: true }] + }, + { + code: "try { somethingRisky(); } catch(e) {\n handleError();\n}", + options: ["1tbs", { allowSingleLine: true }] + }, { code: "if (tag === 1) fontstack.name = pbf.readString(); \nelse if (tag === 2) fontstack.range = pbf.readString(); \nelse if (tag === 3) {\n var glyph = pbf.readMessage(readGlyph, {});\n fontstack.glyphs[glyph.id] = glyph; \n}", options: ["1tbs"]