Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add index to LineResult #234

Open
typed-sigterm opened this issue Feb 9, 2025 · 0 comments
Open

Add index to LineResult #234

typed-sigterm opened this issue Feb 9, 2025 · 0 comments

Comments

@typed-sigterm
Copy link

typed-sigterm commented Feb 9, 2025

Identifying the start index of an issue. (working for #233)

let raw = indoc! { r###"
Hello world

```ts
// hello世界
const a = "string字符串";
```

### 外部test

Second line

```rb
class User
    # 查找user
    def find
    end
end
```
"###};

let expected = indoc! { r###"
{
  "filepath": "md",
  "lines": [
    {
      "l": 4,
      "c": 1,
      "index": 19,
      "new": "// hello 世界",
      "old": "// hello世界",
      "severity": 1
    },
    {
      "l": 5,
      "c": 11,
      "index": 40,
      "new": "\"string 字符串\"",
      "old": "\"string字符串\"",
      "severity": 1
    },
    {
      "l": 8,
      "c": 5,
      "index": 62,
      "new": "外部 test",
      "old": "外部test",
      "severity": 1
    },
    {
      "l": 14,
      "c": 5,
      "index": 104,
      "new": "# 查找 user",
      "old": "# 查找user",
      "severity": 1
    }
  ],
  "error": ""
}
"###};

let result = lint_for(raw, "md");
assert_json_eq!(expected, result.to_json_pretty());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant