Skip to content

Commit 323908a

Browse files
committedSep 25, 2023
Change to improve messages
1 parent 0a586f1 commit 323908a

File tree

3 files changed

+226
-191
lines changed

3 files changed

+226
-191
lines changed
 

‎lib/index.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -525,17 +525,15 @@ function warn(landmarks, reference) {
525525
let ruleId
526526

527527
if (hash) {
528-
reason = 'Link to unknown heading'
528+
reason = 'Cannot find heading for `#' + hash + '`'
529529
ruleId = constants.headingRuleId
530530

531531
if (base && path.join(base, filePath) !== absolute) {
532532
reason += ' in `' + filePath + '`'
533533
ruleId = constants.headingInFileRuleId
534534
}
535-
536-
reason += ': `' + hash + '`'
537535
} else {
538-
reason = 'Link to unknown file: `' + filePath + '`'
536+
reason = 'Cannot find file `' + filePath + '`'
539537
ruleId = constants.fileRuleId
540538
}
541539

@@ -569,17 +567,18 @@ function warn(landmarks, reference) {
569567
})
570568

571569
if (suggestion) {
572-
reason += '. Did you mean `' + suggestion + '`'
570+
reason += '; did you mean `' + suggestion + '`'
573571
}
574572

575573
let index = -1
576574

577575
while (++index < reference.nodes.length) {
578-
const message = reference.file.message(
579-
reason,
580-
reference.nodes[index],
581-
origin
582-
)
576+
const node = reference.nodes[index]
577+
const message = reference.file.message(reason, {
578+
place: node.position,
579+
source: origin,
580+
ruleId
581+
})
583582
message.url = 'https://github.com/remarkjs/remark-validate-links#readme'
584583
}
585584
}

‎package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"c8": "^8.0.0",
6464
"prettier": "^3.0.0",
6565
"remark": "^15.0.0",
66-
"remark-cli": "^11.0.0",
66+
"remark-cli": "^12.0.0",
6767
"remark-preset-wooorm": "^9.0.0",
6868
"strip-ansi": "^7.0.0",
6969
"to-vfile": "^8.0.0",
@@ -74,7 +74,8 @@
7474
},
7575
"scripts": {
7676
"build": "tsc --build --clean && tsc --build && type-coverage",
77-
"format": "remark . --frail --output --quiet && prettier . --log-level warn --write && xo --fix",
77+
"#": "remark . --frail --output --quiet",
78+
"format": "prettier . --log-level warn --write && xo --fix",
7879
"prepack": "npm run build && npm run format",
7980
"test": "npm run build && npm run format && npm run test-coverage",
8081
"test-api": "node --conditions development test/index.js",
@@ -112,7 +113,8 @@
112113
],
113114
"prettier": true,
114115
"rules": {
115-
"unicorn/prefer-logical-operator-over-ternary": "off"
116+
"unicorn/prefer-logical-operator-over-ternary": "off",
117+
"unicorn/prefer-string-replace-all": "off"
116118
}
117119
}
118120
}

‎test/index.js

+212-178
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.