From 37469d47e2c5585b3f9ffbfc43ba2685ef3365ef Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Tue, 23 Jul 2024 13:50:34 +0000 Subject: [PATCH 1/3] Configure `@stylistic/brace-style` rule Despite what the docs say, `1tbs` is not the default configuration for this rule. `1tbs` is our preferred style, so this change configures the rule thusly. --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) 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. From 794e85b7e053e607a4011566d1c4b3a43451d353 Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Tue, 23 Jul 2024 13:51:38 +0000 Subject: [PATCH 2/3] Update test with new brace style error messages --- test/index.test.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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); }); From 8aa4fdd46e46b598ae1721f4da84808114c7a4ee Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Tue, 23 Jul 2024 14:00:14 +0000 Subject: [PATCH 3/3] Bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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",