mirror of
https://github.com/theoludwig/markdownlint-rule-relative-links.git
synced 2025-05-27 11:37:24 +02:00
chore: better Prettier config for easier reviews
This commit is contained in:
@ -1,46 +1,46 @@
|
||||
const test = require('node:test')
|
||||
const assert = require('node:assert/strict')
|
||||
const test = require("node:test")
|
||||
const assert = require("node:assert/strict")
|
||||
|
||||
const { markdownlint } = require('markdownlint').promises
|
||||
const { markdownlint } = require("markdownlint").promises
|
||||
|
||||
const relativeLinks = require('../src/index.js')
|
||||
const relativeLinks = require("../src/index.js")
|
||||
|
||||
test('ensure the rule validate correctly', async () => {
|
||||
test("ensure the rule validate correctly", async () => {
|
||||
const lintResults = await markdownlint({
|
||||
files: ['test/fixtures/Valid.md', 'test/fixtures/Invalid.md'],
|
||||
files: ["test/fixtures/Valid.md", "test/fixtures/Invalid.md"],
|
||||
config: {
|
||||
default: false,
|
||||
'relative-links': true
|
||||
"relative-links": true,
|
||||
},
|
||||
customRules: [relativeLinks]
|
||||
customRules: [relativeLinks],
|
||||
})
|
||||
assert.equal(lintResults['test/fixtures/Valid.md'].length, 0)
|
||||
assert.equal(lintResults['test/fixtures/Invalid.md'].length, 3)
|
||||
assert.equal(lintResults["test/fixtures/Valid.md"].length, 0)
|
||||
assert.equal(lintResults["test/fixtures/Invalid.md"].length, 3)
|
||||
|
||||
assert.equal(
|
||||
lintResults['test/fixtures/Invalid.md'][0]?.ruleDescription,
|
||||
'Relative links should be valid'
|
||||
lintResults["test/fixtures/Invalid.md"][0]?.ruleDescription,
|
||||
"Relative links should be valid",
|
||||
)
|
||||
assert.equal(
|
||||
lintResults['test/fixtures/Invalid.md'][0]?.errorDetail,
|
||||
'Link "./basic.test.js" should exist in the file system'
|
||||
lintResults["test/fixtures/Invalid.md"][0]?.errorDetail,
|
||||
'Link "./basic.test.js" should exist in the file system',
|
||||
)
|
||||
|
||||
assert.equal(
|
||||
lintResults['test/fixtures/Invalid.md'][1]?.ruleDescription,
|
||||
'Relative links should be valid'
|
||||
lintResults["test/fixtures/Invalid.md"][1]?.ruleDescription,
|
||||
"Relative links should be valid",
|
||||
)
|
||||
assert.equal(
|
||||
lintResults['test/fixtures/Invalid.md'][1]?.errorDetail,
|
||||
'Link "../image.png" should exist in the file system'
|
||||
lintResults["test/fixtures/Invalid.md"][1]?.errorDetail,
|
||||
'Link "../image.png" should exist in the file system',
|
||||
)
|
||||
|
||||
assert.equal(
|
||||
lintResults['test/fixtures/Invalid.md'][2]?.ruleDescription,
|
||||
'Relative links should be valid'
|
||||
lintResults["test/fixtures/Invalid.md"][2]?.ruleDescription,
|
||||
"Relative links should be valid",
|
||||
)
|
||||
assert.equal(
|
||||
lintResults['test/fixtures/Invalid.md'][2]?.errorDetail,
|
||||
'Link "./Valid.md#not-existing-heading" should have a valid fragment'
|
||||
lintResults["test/fixtures/Invalid.md"][2]?.errorDetail,
|
||||
'Link "./Valid.md#not-existing-heading" should have a valid fragment',
|
||||
)
|
||||
})
|
||||
|
@ -1,37 +1,37 @@
|
||||
const test = require('node:test')
|
||||
const assert = require('node:assert/strict')
|
||||
const test = require("node:test")
|
||||
const assert = require("node:assert/strict")
|
||||
|
||||
const {
|
||||
convertHeadingToHTMLFragment,
|
||||
getMarkdownHeadings
|
||||
} = require('../src/utils.js')
|
||||
getMarkdownHeadings,
|
||||
} = require("../src/utils.js")
|
||||
|
||||
test('utils', async (t) => {
|
||||
await t.test('convertHeadingToHTMLFragment', async () => {
|
||||
test("utils", async (t) => {
|
||||
await t.test("convertHeadingToHTMLFragment", async () => {
|
||||
assert.strictEqual(
|
||||
convertHeadingToHTMLFragment('Valid Fragments'),
|
||||
'#valid-fragments'
|
||||
convertHeadingToHTMLFragment("Valid Fragments"),
|
||||
"#valid-fragments",
|
||||
)
|
||||
assert.strictEqual(
|
||||
convertHeadingToHTMLFragment('Valid Heading With Underscores _'),
|
||||
'#valid-heading-with-underscores-_'
|
||||
convertHeadingToHTMLFragment("Valid Heading With Underscores _"),
|
||||
"#valid-heading-with-underscores-_",
|
||||
)
|
||||
assert.strictEqual(
|
||||
convertHeadingToHTMLFragment(
|
||||
`Valid Heading With Quotes ' And Double Quotes "`
|
||||
`Valid Heading With Quotes ' And Double Quotes "`,
|
||||
),
|
||||
'#valid-heading-with-quotes--and-double-quotes-'
|
||||
"#valid-heading-with-quotes--and-double-quotes-",
|
||||
)
|
||||
assert.strictEqual(
|
||||
convertHeadingToHTMLFragment('🚀 Valid Heading With Emoji'),
|
||||
'#-valid-heading-with-emoji'
|
||||
convertHeadingToHTMLFragment("🚀 Valid Heading With Emoji"),
|
||||
"#-valid-heading-with-emoji",
|
||||
)
|
||||
})
|
||||
|
||||
await t.test('getMarkdownHeadings', async () => {
|
||||
await t.test("getMarkdownHeadings", async () => {
|
||||
assert.deepStrictEqual(
|
||||
getMarkdownHeadings('# Hello\n\n## World\n\n## Hello, world!\n'),
|
||||
['Hello', 'World', 'Hello, world!']
|
||||
getMarkdownHeadings("# Hello\n\n## World\n\n## Hello, world!\n"),
|
||||
["Hello", "World", "Hello, world!"],
|
||||
)
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user