Skip to content

Commit 8cae2a5

Browse files
committed
chore: re-enable the no-regex-spaces ESLint rule
no-regex-spaces was disabled in src/eslint.config.mjs under a "TODO: re-enable" comment. The 40 violations are auto-fixed — consecutive literal spaces in a regex are replaced with an explicit {n} quantifier, which matches identically — and the override is removed so the rule is enforced again (eslint:recommended provides it via the shared base config).
1 parent b40461d commit 8cae2a5

7 files changed

Lines changed: 40 additions & 43 deletions

src/eslint.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export default [
66
{
77
rules: {
88
// TODO: These should be fixed and the rules re-enabled.
9-
"no-regex-spaces": "off",
109
"no-useless-escape": "off",
1110
"no-empty": "off",
1211
"prefer-const": "off",

src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.elixir.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,46 +44,46 @@ describe("parseSourceCodeDefinitionsForFile with Elixir", () => {
4444
})
4545

4646
it("should parse function definitions", () => {
47-
expect(parseResult).toMatch(/\d+--\d+ \| def test_function_definition/)
48-
expect(parseResult).toMatch(/\d+--\d+ \| def test_pipeline_definition/)
49-
expect(parseResult).toMatch(/\d+--\d+ \| def test_comprehension_definition/)
50-
expect(parseResult).toMatch(/\d+--\d+ \| def test_sigil_definition/)
47+
expect(parseResult).toMatch(/\d+--\d+ \| {3}def test_function_definition/)
48+
expect(parseResult).toMatch(/\d+--\d+ \| {3}def test_pipeline_definition/)
49+
expect(parseResult).toMatch(/\d+--\d+ \| {3}def test_comprehension_definition/)
50+
expect(parseResult).toMatch(/\d+--\d+ \| {3}def test_sigil_definition/)
5151
debugLog("Function definitions found:", parseResult.match(/def[\s\S]*?end/g))
5252
})
5353

5454
it("should parse macro definitions", () => {
55-
expect(parseResult).toMatch(/\d+--\d+ \| defmacro test_macro_definition/)
55+
expect(parseResult).toMatch(/\d+--\d+ \| {3}defmacro test_macro_definition/)
5656
debugLog("Macro definitions found:", parseResult.match(/defmacro[\s\S]*?end/g))
5757
})
5858

5959
it("should parse protocol implementations", () => {
60-
expect(parseResult).toMatch(/\d+--\d+ \| defimpl String\.Chars/)
60+
expect(parseResult).toMatch(/\d+--\d+ \| {3}defimpl String\.Chars/)
6161
debugLog("Protocol implementations found:", parseResult.match(/defimpl[\s\S]*?end/g))
6262
})
6363

6464
it("should parse behaviour callbacks", () => {
65-
expect(parseResult).toMatch(/\d+--\d+ \| @callback test_behaviour_callback/)
65+
expect(parseResult).toMatch(/\d+--\d+ \| {3}@callback test_behaviour_callback/)
6666
debugLog("Behaviour callbacks found:", parseResult.match(/@callback[\s\S]*?\)/g))
6767
})
6868

6969
it("should parse struct definitions", () => {
70-
expect(parseResult).toMatch(/\d+--\d+ \| defstruct \[/)
70+
expect(parseResult).toMatch(/\d+--\d+ \| {3}defstruct \[/)
7171
debugLog("Struct definitions found:", parseResult.match(/defstruct[\s\S]*?\]/g))
7272
})
7373

7474
it("should parse guard definitions", () => {
75-
expect(parseResult).toMatch(/\d+--\d+ \| defguard test_guard_definition/)
75+
expect(parseResult).toMatch(/\d+--\d+ \| {3}defguard test_guard_definition/)
7676
debugLog("Guard definitions found:", parseResult.match(/defguard[\s\S]*?end/g))
7777
})
7878

7979
it("should parse module attributes", () => {
80-
expect(parseResult).toMatch(/\d+--\d+ \| @test_attribute_definition/)
80+
expect(parseResult).toMatch(/\d+--\d+ \| {3}@test_attribute_definition/)
8181
expect(parseResult).toMatch(/\d+--\d+ \| @moduledoc/)
8282
debugLog("Module attributes found:", parseResult.match(/@[\s\S]*?\]/g))
8383
})
8484

8585
it("should parse test definitions", () => {
86-
expect(parseResult).toMatch(/\d+--\d+ \| test "test_definition"/)
86+
expect(parseResult).toMatch(/\d+--\d+ \| {3}test "test_definition"/)
8787
debugLog("Test definitions found:", parseResult.match(/test[\s\S]*?end/g))
8888
})
8989
})

src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.python.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("parseSourceCodeDefinitionsForFile with Python", () => {
4646
it("should parse class and method definitions", () => {
4747
expect(parseResult).toMatch(/\d+--\d+ \| class MultiLineDecoratedClass:/)
4848
expect(parseResult).toMatch(/\d+--\d+ \| class MethodContainer:/)
49-
expect(parseResult).toMatch(/\d+--\d+ \| def multi_line_method\(/)
49+
expect(parseResult).toMatch(/\d+--\d+ \| {5}def multi_line_method\(/)
5050
debugLog("Class and method definitions found:", parseResult)
5151
})
5252

src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.scala.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ describe("parseSourceCodeDefinitionsForFile with Scala", () => {
6262
})
6363

6464
it("should parse method declarations", () => {
65-
expect(parseResult).toMatch(/\d+--\d+ \| def testMatch\(value: Any\): Int = value match/)
66-
expect(parseResult).toMatch(/\d+--\d+ \| def processItems\(items: List\[Int\]\): List\[Int\]/)
65+
expect(parseResult).toMatch(/\d+--\d+ \| {3}def testMatch\(value: Any\): Int = value match/)
66+
expect(parseResult).toMatch(/\d+--\d+ \| {3}def processItems\(items: List\[Int\]\): List\[Int\]/)
6767
})
6868

6969
it("should parse value declarations", () => {
70-
expect(parseResult).toMatch(/\d+--\d+ \| lazy val heavyComputation: Int = \{/)
71-
expect(parseResult).toMatch(/\d+--\d+ \| val immutableValue: Int = 42/)
70+
expect(parseResult).toMatch(/\d+--\d+ \| {3}lazy val heavyComputation: Int = \{/)
71+
expect(parseResult).toMatch(/\d+--\d+ \| {3}val immutableValue: Int = 42/)
7272
})
7373

7474
it("should parse variable declarations", () => {
75-
expect(parseResult).toMatch(/\d+--\d+ \| var mutableValue: String = "changeable"/)
75+
expect(parseResult).toMatch(/\d+--\d+ \| {3}var mutableValue: String = "changeable"/)
7676
})
7777

7878
it("should parse type definitions", () => {
79-
expect(parseResult).toMatch(/\d+--\d+ \| type StringMap\[T\] = Map\[String, T\]/)
79+
expect(parseResult).toMatch(/\d+--\d+ \| {3}type StringMap\[T\] = Map\[String, T\]/)
8080
})
8181

8282
/*

src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.solidity.spec.ts

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,53 +24,51 @@ describe("Solidity Source Code Definition Tests", () => {
2424
})
2525

2626
it("should parse using directives", () => {
27-
expect(parseResult).toMatch(/23--23 \| using MathLib for uint256;/)
27+
expect(parseResult).toMatch(/23--23 \| {5}using MathLib for uint256;/)
2828
})
2929

3030
it("should parse type declarations", () => {
31-
expect(parseResult).toMatch(/25--30 \| struct UserInfo {/)
32-
expect(parseResult).toMatch(/32--37 \| enum UserRole {/)
31+
expect(parseResult).toMatch(/25--30 \| {5}struct UserInfo {/)
32+
expect(parseResult).toMatch(/32--37 \| {5}enum UserRole {/)
3333
})
3434

3535
it("should parse state variable declarations", () => {
36-
expect(parseResult).toMatch(/39--39 \| uint256 private immutable totalSupply;/)
37-
expect(parseResult).toMatch(/40--40 \| mapping\(address => UserInfo\) private users;/)
38-
expect(parseResult).toMatch(/41--41 \| UserRole\[\] private roles;/)
36+
expect(parseResult).toMatch(/39--39 \| {5}uint256 private immutable totalSupply;/)
37+
expect(parseResult).toMatch(/40--40 \| {5}mapping\(address => UserInfo\) private users;/)
38+
expect(parseResult).toMatch(/41--41 \| {5}UserRole\[\] private roles;/)
3939
})
4040
it("should parse function declarations", () => {
41-
expect(parseResult).toMatch(/70--87 \| function transfer\(/)
42-
expect(parseResult).toMatch(/89--93 \| function interfaceFunction\(/)
41+
expect(parseResult).toMatch(/70--87 \| {5}function transfer\(/)
42+
expect(parseResult).toMatch(/89--93 \| {5}function interfaceFunction\(/)
43+
expect(parseResult).toMatch(/6--6 \| {5}function interfaceFunction\(uint256 value\) external returns \(bool\);/)
4344
expect(parseResult).toMatch(
44-
/6--6 \| function interfaceFunction\(uint256 value\) external returns \(bool\);/,
45+
/12--14 \| {5}function add\(uint256 a, uint256 b\) internal pure returns \(uint256\) {/,
4546
)
4647
expect(parseResult).toMatch(
47-
/12--14 \| function add\(uint256 a, uint256 b\) internal pure returns \(uint256\) {/,
48-
)
49-
expect(parseResult).toMatch(
50-
/16--19 \| function subtract\(uint256 a, uint256 b\) internal pure returns \(uint256\) {/,
48+
/16--19 \| {5}function subtract\(uint256 a, uint256 b\) internal pure returns \(uint256\) {/,
5149
)
5250
})
5351

5452
it("should parse constructor declarations", () => {
55-
expect(parseResult).toMatch(/63--68 \| constructor\(uint256 _initialSupply\) {/)
53+
expect(parseResult).toMatch(/63--68 \| {5}constructor\(uint256 _initialSupply\) {/)
5654
})
5755

5856
it("should parse special function declarations", () => {
59-
expect(parseResult).toMatch(/95--97 \| fallback\(\) external payable {/)
60-
expect(parseResult).toMatch(/99--101 \| receive\(\) external payable {/)
57+
expect(parseResult).toMatch(/95--97 \| {5}fallback\(\) external payable {/)
58+
expect(parseResult).toMatch(/99--101 \| {5}receive\(\) external payable {/)
6159
})
6260

6361
it("should parse event declarations", () => {
64-
expect(parseResult).toMatch(/43--47 \| event Transfer\(/)
65-
expect(parseResult).toMatch(/7--7 \| event InterfaceEvent\(address indexed sender, uint256 value\);/)
62+
expect(parseResult).toMatch(/43--47 \| {5}event Transfer\(/)
63+
expect(parseResult).toMatch(/7--7 \| {5}event InterfaceEvent\(address indexed sender, uint256 value\);/)
6664
})
6765

6866
it("should parse error declarations", () => {
69-
expect(parseResult).toMatch(/49--53 \| error InsufficientBalance\(/)
70-
expect(parseResult).toMatch(/8--8 \| error InterfaceError\(string message\);/)
67+
expect(parseResult).toMatch(/49--53 \| {5}error InsufficientBalance\(/)
68+
expect(parseResult).toMatch(/8--8 \| {5}error InterfaceError\(string message\);/)
7169
})
7270

7371
it("should parse modifier declarations", () => {
74-
expect(parseResult).toMatch(/55--61 \| modifier onlyAdmin\(\) {/)
72+
expect(parseResult).toMatch(/55--61 \| {5}modifier onlyAdmin\(\) {/)
7573
})
7674
})

src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.toml.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe("TOML Source Code Definition Tests", () => {
4141

4242
it("should parse table arrays", () => {
4343
expect(parseResult).toMatch(/\d+--\d+ \|\s*\[\[products\]\]/)
44-
expect(parseResult).toMatch(/\d+--\d+ \|\s*\[\[products\]\] # Array of tables/)
44+
expect(parseResult).toMatch(/\d+--\d+ \|\s*\[\[products\]\] {2}# Array of tables/)
4545
})
4646

4747
it("should parse inline tables", () => {

src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.zig.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ describe("Zig Source Code Definition Tests", () => {
1919

2020
it("should parse function definitions", () => {
2121
expect(parseResult).toMatch(/\d+--\d+ \| pub fn main\(\) !void/)
22-
expect(parseResult).toMatch(/\d+--\d+ \| pub fn init\(x: f32, y: f32\) Point/)
23-
expect(parseResult).toMatch(/\d+--\d+ \| pub fn distance\(self: Point\) f32/)
22+
expect(parseResult).toMatch(/\d+--\d+ \| {5}pub fn init\(x: f32, y: f32\) Point/)
23+
expect(parseResult).toMatch(/\d+--\d+ \| {5}pub fn distance\(self: Point\) f32/)
2424
})
2525

2626
it("should parse container definitions", () => {

0 commit comments

Comments
 (0)