Skip to content

Commit

Permalink
Add tests for filename with lowercase, uppercase, slashes, and spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Feb 17, 2025
1 parent 7cccc3e commit 235afbc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/fixtures/filename.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Test

```js filename="a/b/C D E.js"
console.log("...");
```
15 changes: 15 additions & 0 deletions tests/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,21 @@ describe("FlatESLint", () => {
assert.strictEqual(results[0].messages[4].column, 2);
});

it("parses when file name includes lowercase, uppercase, slashes, and spaces", async () => {
const results = await eslint.lintFiles([
path.resolve(__dirname, "./fixtures/filename.md"),
]);

assert.strictEqual(results.length, 1);
assert.strictEqual(results[0].messages.length, 1);
assert.strictEqual(
results[0].messages[0].message,
"Unexpected console statement.",
);
assert.strictEqual(results[0].messages[0].line, 4);
assert.strictEqual(results[0].messages[0].column, 1);
});

// https://github.com/eslint/markdown/issues/181
it("should work when called on nested code blocks in the same file", async () => {
/*
Expand Down
14 changes: 14 additions & 0 deletions tests/processor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,20 @@ describe("processor", () => {
assert.strictEqual(blocks[0].filename, "abc/def.js");
});

it("should parse a filename with lowercase, uppercase, slashes, and spaces", () => {
const code =
prefix +
[
"``` js filename='a/b/C D E.js'",
"var answer = 6 * 7;",
"```",
].join("\n");
const blocks = processor.preprocess(code);

assert.strictEqual(blocks.length, 1);
assert.strictEqual(blocks[0].filename, "a/b/C D E.js");
});

it("should parse a filename each from two meta", () => {
const code =
prefix +
Expand Down

0 comments on commit 235afbc

Please sign in to comment.