PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: platers/obsidian-linter (ts)

Issue:
Bug: Crash when email address added as an alias 
## Describe the Bug

Linter crashes if a file contains an email address as an alias

## How to Reproduce

Example to reproduce issue:

``` markdown
---
title: John & Jane Doe
aliases: [John & Jane Doe, email@example.xyz, (123) 456-7890]
cssclass: [table-lines-bright, col-lines, row-lines]
---

# John & Jane Doe

This stuff doesn't really matter.

```

Please make sure to include the rule(s) that cause the issue if applicable. If you are not sure which rule(s) may cause the issue, please attach the `data.json` file located at `<vault>/.obsidian/plugins/obsidian-linter/`.

## Expected Behavior

I expect lint4er not to crash.

## Screenshots

![image](https://user-images.githubusercontent.com/1509989/184920007-00359623-2c95-4370-a70e-bc4677598f65.png)


## Device

- [x] Desktop
- [ ] Mobile

## Additional Context

Attached data.json.txt

This may be a problem with compatibility with meta-edit. 

[data.json.txt](https://github.com/platers/obsidian-linter/files/9352373/data.json.txt)



Pull request:
Fixes an Issue with Undefined Positions for Link Spacing
Fixes #360 

Changes Made:
- Added a UT to hopefully keep from running into this issue again in the future
- Made sure to skip any links with undefined positions

Patch:
diff --git a/src/utils/mdast.ts b/src/utils/mdast.ts
index 45ecb94..bd1fe17 100644
--- a/src/utils/mdast.ts
+++ b/src/utils/mdast.ts
@@ -275,6 +275,10 @@ export function removeSpacesInLinkText(text: string): string {
   const positions: Position[] = getPositions(MDAstTypes.Link, text);
 
   for (const position of positions) {
+    if (position == null) {
+      continue;
+    }
+
     const regularLink = text.substring(position.start.offset, position.end.offset);
     // skip links that are not are not in markdown format
     if (!regularLink.match(genericLinkRegex)) {


Test patch:
diff --git a/__tests__/remove-link-spacing.test.ts b/__tests__/remove-link-spacing.test.ts
index 678d7f8..b9eb246 100644
--- a/__tests__/remove-link-spacing.test.ts
+++ b/__tests__/remove-link-spacing.test.ts
@@ -17,5 +17,32 @@ ruleTest({
         - [ ] [[fileName]]
       `,
     },
+    {
+      // accounts for https://github.com/platers/obsidian-linter/issues/236
+      testName: 'Alias with an email in it should not cause an issue',
+      before: dedent`
+        ---
+        title: John & Jane Doe
+        aliases: [John & Jane Doe, email@example.xyz, (123) 456-7890]
+        cssclass: [table-lines-bright, col-lines, row-lines]
+        ---
+
+        # John & Jane Doe
+
+        This stuff doesn't really matter.
+      `,
+      after: dedent`
+        ---
+        title: John & Jane Doe
+        aliases: [John & Jane Doe, email@example.xyz, (123) 456-7890]
+        cssclass: [table-lines-bright, col-lines, row-lines]
+        ---
+
+        # John & Jane Doe
+
+        This stuff doesn't really matter.
+      `,
+    },
   ],
 });
+