diff --git a/index.js b/index.js index dd5c298..fb5a339 100644 --- a/index.js +++ b/index.js @@ -57,6 +57,13 @@ export default [ */ "@stylistic/array-element-newline": ["error", "consistent"], + /** + * Enforce consistent brace style for blocks. + * + * @see {@link https://eslint.style/rules/default/brace-style} + */ + "@stylistic/brace-style": ["error", "1tbs"], + /** * Enforce consistent usage of line breaks between arguments of a function * call. diff --git a/package-lock.json b/package-lock.json index 8747d79..fb50e88 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cargosense/eslint-config", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cargosense/eslint-config", - "version": "1.1.0", + "version": "1.2.0", "license": "MIT", "dependencies": { "@eslint/js": "^9.7.0", diff --git a/package.json b/package.json index 700b031..3ba1594 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" :"@cargosense/eslint-config", - "version": "1.1.0", + "version": "1.2.0", "description": "Shareable ESLint configuration.", "keywords": [ "eslint-config", diff --git a/test/index.test.js b/test/index.test.js index a0f00fc..f5218ac 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -28,6 +28,18 @@ test("loads config and invalidates incorrect syntax", async () => { }); const expected = [ + { + column: 8, + endColumn: 9, + endLine: 1, + fix: { range: [8, 8], text: "\n" }, + line: 1, + message: "Statement inside of curly braces should be on next line.", + messageId: "blockSameLine", + nodeType: "Punctuator", + ruleId: "@stylistic/brace-style", + severity: 2, + }, { column: 10, endColumn: 26, @@ -51,6 +63,18 @@ test("loads config and invalidates incorrect syntax", async () => { ruleId: "array-func/prefer-flat-map", severity: 2, }, + { + column: 27, + endColumn: 28, + endLine: 1, + fix: { range: [26, 26], text: "\n" }, + line: 1, + message: "Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.", + messageId: "singleLineClose", + nodeType: "Punctuator", + ruleId: "@stylistic/brace-style", + severity: 2, + }, { column: 28, fix: { range: [28, 29], text: "" }, @@ -75,6 +99,6 @@ test("loads config and invalidates incorrect syntax", async () => { }, ]; - assert.strictEqual(errorCount, 4); + assert.strictEqual(errorCount, 6); assert.deepEqual(messages, expected); });