Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,23 @@
"test:types": "tsc -p tests/types/tsconfig.json"
},
"devDependencies": {
"@eslint/js": "^9.31.0",
"@eslint/json": "^0.13.1",
"@eslint/js": "^9.36.0",
"@eslint/json": "^0.13.2",
"c8": "^10.1.3",
"dedent": "^1.5.3",
"eslint": "^9.35.0",
"eslint": "^9.36.0",
"eslint-config-eslint": "^13.0.0",
"eslint-plugin-eslint-plugin": "^6.3.2",
"globals": "^16.0.0",
"globals": "^16.4.0",
"lint-staged": "^15.2.9",
"mocha": "^11.6.0",
"prettier": "^3.3.3",
"typescript": "^5.9.2",
"yorkie": "^2.0.0"
},
"dependencies": {
"@eslint/core": "^0.15.2",
"@eslint/plugin-kit": "^0.3.5",
"@eslint/core": "^0.16.0",
"@eslint/plugin-kit": "^0.4.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @eslint/plugin-kit v0.4.0 has been released, we could now continue work here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was some delay on my end with the markdown plugin. I'll work on it soon! 👍

"github-slugger": "^2.0.0",
"mdast-util-from-markdown": "^2.0.2",
"mdast-util-frontmatter": "^2.0.1",
Expand Down
126 changes: 126 additions & 0 deletions tests/language/markdown-source-code.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,132 @@ describe("MarkdownSourceCode", () => {
});
});

describe("getLocFromIndex()", () => {
it("should convert index to location correctly", () => {
const text = "foo\nbar\r\nbaz";
const markdownSourceCode = new MarkdownSourceCode({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used the markdownSourceCode name here because the following errors occur:

110:10  error  'sourceCode' is already declared in the upper scope on line 63 column 6  no-shadow
173:10  error  'sourceCode' is already declared in the upper scope on line 63 column 6  no-shadow

text,
ast: fromMarkdown(text),
});

assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(0), {
line: 1,
column: 1,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(1), {
line: 1,
column: 2,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(2), {
line: 1,
column: 3,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(3), {
line: 1,
column: 4,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(4), {
line: 2,
column: 1,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(5), {
line: 2,
column: 2,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(6), {
line: 2,
column: 3,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(7), {
line: 2,
column: 4,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(8), {
line: 2,
column: 5,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(9), {
line: 3,
column: 1,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(10), {
line: 3,
column: 2,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(11), {
line: 3,
column: 3,
});
assert.deepStrictEqual(markdownSourceCode.getLocFromIndex(12), {
line: 3,
column: 4,
});
});
});

describe("getIndexFromLoc()", () => {
it("should convert location to index correctly", () => {
const text = "foo\nbar\r\nbaz";
const markdownSourceCode = new MarkdownSourceCode({
text,
ast: fromMarkdown(text),
});

assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 1, column: 1 }),
0,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 1, column: 2 }),
1,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 1, column: 3 }),
2,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 1, column: 4 }),
3,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 2, column: 1 }),
4,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 2, column: 2 }),
5,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 2, column: 3 }),
6,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 2, column: 4 }),
7,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 2, column: 5 }),
8,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 3, column: 1 }),
9,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 3, column: 2 }),
10,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 3, column: 3 }),
11,
);
assert.strictEqual(
markdownSourceCode.getIndexFromLoc({ line: 3, column: 4 }),
12,
);
});
});

describe("getInlineConfigNodes()", () => {
it("should return the inline config nodes", () => {
const nodes = sourceCode.getInlineConfigNodes();
Expand Down
5 changes: 5 additions & 0 deletions tests/types/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ typeof processorPlugins satisfies {};
parent?: Parent | undefined,
) {
sourceCode.getLoc(node) satisfies SourceLocation;
sourceCode.getLocFromIndex(0) satisfies {
line: number;
column: number;
};
sourceCode.getIndexFromLoc({ line: 1, column: 1 }) satisfies number;
sourceCode.getRange(node) satisfies SourceRange;
sourceCode.getParent(node) satisfies Node | undefined;
sourceCode.getAncestors(node) satisfies Node[];
Expand Down
Loading