chore: migrate from ESLint/Prettier to Oxc

This commit is contained in:
2026-02-05 17:29:13 +01:00
parent 075742e867
commit 12a22980ce
13 changed files with 561 additions and 2223 deletions

View File

@@ -35,22 +35,18 @@ test("ensure the rule validates correctly", async (t) => {
const testCases = [
{
name: "should be invalid with an empty id fragment",
fixturePath:
"test/fixtures/invalid/empty-id-fragment/empty-id-fragment.md",
fixturePath: "test/fixtures/invalid/empty-id-fragment/empty-id-fragment.md",
errors: ['"./awesome.md#" should have a valid fragment identifier'],
},
{
name: "should be invalid with a name fragment other than for an anchor",
fixturePath:
"test/fixtures/invalid/ignore-name-fragment-if-not-an-anchor/ignore-name-fragment-if-not-an-anchor.md",
errors: [
'"./awesome.md#name-should-be-ignored" should have a valid fragment identifier',
],
errors: ['"./awesome.md#name-should-be-ignored" should have a valid fragment identifier'],
},
{
name: "should be invalid with a non-existing id fragment (data-id !== id)",
fixturePath:
"test/fixtures/invalid/ignore-not-an-id-fragment/ignore-not-an-id-fragment.md",
fixturePath: "test/fixtures/invalid/ignore-not-an-id-fragment/ignore-not-an-id-fragment.md",
errors: [
'"./awesome.md#not-an-id-should-be-ignored" should have a valid fragment identifier',
],
@@ -59,17 +55,13 @@ test("ensure the rule validates correctly", async (t) => {
name: "should be invalid with uppercase letters in fragment (case sensitive)",
fixturePath:
"test/fixtures/invalid/invalid-heading-case-sensitive/invalid-heading-case-sensitive.md",
errors: [
'"./awesome.md#ExistIng-Heading" should have a valid fragment identifier',
],
errors: ['"./awesome.md#ExistIng-Heading" should have a valid fragment identifier'],
},
{
name: "should be invalid with invalid heading with #L fragment",
fixturePath:
"test/fixtures/invalid/invalid-heading-with-L-fragment/invalid-heading-with-L-fragment.md",
errors: [
'"./awesome.md#L7abc" should have a valid fragment identifier',
],
errors: ['"./awesome.md#L7abc" should have a valid fragment identifier'],
},
{
name: "should be invalid with a invalid line column range number fragment",
@@ -121,22 +113,16 @@ test("ensure the rule validates correctly", async (t) => {
name: "should be invalid with a non-existing heading fragment",
fixturePath:
"test/fixtures/invalid/non-existing-heading-fragment/non-existing-heading-fragment.md",
errors: [
'"./awesome.md#non-existing-heading" should have a valid fragment identifier',
],
errors: ['"./awesome.md#non-existing-heading" should have a valid fragment identifier'],
},
{
name: "should be invalid with a link to an image with a empty fragment",
fixturePath:
"test/fixtures/invalid/ignore-empty-fragment-checking-for-image.md",
errors: [
'"../image.png#" should not have a fragment identifier as it is an image',
],
fixturePath: "test/fixtures/invalid/ignore-empty-fragment-checking-for-image.md",
errors: ['"../image.png#" should not have a fragment identifier as it is an image'],
},
{
name: "should be invalid with a link to an image with a fragment",
fixturePath:
"test/fixtures/invalid/ignore-fragment-checking-for-image.md",
fixturePath: "test/fixtures/invalid/ignore-fragment-checking-for-image.md",
errors: [
'"../image.png#non-existing-fragment" should not have a fragment identifier as it is an image',
],
@@ -163,28 +149,15 @@ test("ensure the rule validates correctly", async (t) => {
},
]
for (const {
name,
fixturePath,
errors,
config = defaultConfig,
} of testCases) {
for (const { name, fixturePath, errors, config = defaultConfig } of testCases) {
await t.test(name, async () => {
const lintResults =
(await validateMarkdownLint(fixturePath, config)) ?? []
const lintResults = (await validateMarkdownLint(fixturePath, config)) ?? []
const errorsDetails = lintResults.map((result) => {
assert.deepEqual(result.ruleNames, relativeLinksRule.names)
assert.deepEqual(
result.ruleDescription,
relativeLinksRule.description,
)
assert.deepEqual(result.ruleDescription, relativeLinksRule.description)
return result.errorDetail
})
assert.deepStrictEqual(
errorsDetails,
errors,
`${fixturePath}: Expected errors`,
)
assert.deepStrictEqual(errorsDetails, errors, `${fixturePath}: Expected errors`)
})
}
})
@@ -203,8 +176,7 @@ test("ensure the rule validates correctly", async (t) => {
},
{
name: "should be valid with an existing heading fragment",
fixturePath:
"test/fixtures/valid/existing-heading-fragment/existing-heading-fragment.md",
fixturePath: "test/fixtures/valid/existing-heading-fragment/existing-heading-fragment.md",
},
{
name: 'should be valid with an existing heading fragment with accents (e.g: "é")',
@@ -228,8 +200,7 @@ test("ensure the rule validates correctly", async (t) => {
},
{
name: "should be valid with valid line number fragment",
fixturePath:
"test/fixtures/valid/valid-line-number-fragment/valid-line-number-fragment.md",
fixturePath: "test/fixtures/valid/valid-line-number-fragment/valid-line-number-fragment.md",
},
{
name: "should be valid with an existing file",
@@ -249,8 +220,7 @@ test("ensure the rule validates correctly", async (t) => {
},
{
name: "should ignore checking fragment in own file",
fixturePath:
"test/fixtures/valid/ignore-fragment-checking-in-own-file.md",
fixturePath: "test/fixtures/valid/ignore-fragment-checking-in-own-file.md",
},
{
name: "should be valid with correct absolute paths if root_path is set",
@@ -265,8 +235,7 @@ test("ensure the rule validates correctly", async (t) => {
for (const { name, fixturePath, config = defaultConfig } of testCases) {
await t.test(name, async () => {
const lintResults =
(await validateMarkdownLint(fixturePath, config)) ?? []
const lintResults = (await validateMarkdownLint(fixturePath, config)) ?? []
const errorsDetails = lintResults.map((result) => {
return result.errorDetail
})

View File

@@ -12,18 +12,13 @@ import {
test("utils", async (t) => {
await t.test("convertHeadingToHTMLFragment", async () => {
assert.strictEqual(
convertHeadingToHTMLFragment("Valid Fragments"),
"#valid-fragments",
)
assert.strictEqual(convertHeadingToHTMLFragment("Valid Fragments"), "#valid-fragments")
assert.strictEqual(
convertHeadingToHTMLFragment("Valid Heading With Underscores _"),
"#valid-heading-with-underscores-_",
)
assert.strictEqual(
convertHeadingToHTMLFragment(
`Valid Heading With Quotes ' And Double Quotes "`,
),
convertHeadingToHTMLFragment(`Valid Heading With Quotes ' And Double Quotes "`),
"#valid-heading-with-quotes--and-double-quotes-",
)
assert.strictEqual(
@@ -33,27 +28,22 @@ test("utils", async (t) => {
})
await t.test("getMarkdownHeadings", async () => {
assert.deepStrictEqual(
getMarkdownHeadings("# Hello\n\n## World\n\n## Hello, world!\n"),
["Hello", "World", "Hello, world!"],
)
assert.deepStrictEqual(getMarkdownHeadings("# Hello\n\n## World\n\n## Hello, world!\n"), [
"Hello",
"World",
"Hello, world!",
])
})
await t.test("getMarkdownIdOrAnchorNameFragments", async () => {
assert.deepStrictEqual(
getMarkdownIdOrAnchorNameFragments(
'<a name="anchorName" id="anchorId">Link</a>',
),
getMarkdownIdOrAnchorNameFragments('<a name="anchorName" id="anchorId">Link</a>'),
["#anchorId"],
)
assert.deepStrictEqual(
getMarkdownIdOrAnchorNameFragments('<a name="anchorName">Link</a>'),
["#anchorName"],
)
assert.deepStrictEqual(
getMarkdownIdOrAnchorNameFragments("<a>Link</a>"),
[],
)
assert.deepStrictEqual(getMarkdownIdOrAnchorNameFragments('<a name="anchorName">Link</a>'), [
"#anchorName",
])
assert.deepStrictEqual(getMarkdownIdOrAnchorNameFragments("<a>Link</a>"), [])
assert.deepStrictEqual(getMarkdownIdOrAnchorNameFragments("<a>"), [])
assert.deepStrictEqual(getMarkdownIdOrAnchorNameFragments("<a id=>"), [])
})