-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure severity with unified-lint-rule #67
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -41,6 +41,7 @@ | |||||||||||||||||||||||||||||||||
* Otherwise, use `urlConfig` to specify this manually. | ||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
import {lintRule} from 'unified-lint-rule' | ||||||||||||||||||||||||||||||||||
import {check} from './check/index.js' | ||||||||||||||||||||||||||||||||||
import {find} from './find/index.js' | ||||||||||||||||||||||||||||||||||
import {constants} from './constants.js' | ||||||||||||||||||||||||||||||||||
|
@@ -51,30 +52,45 @@ cliCompleter.pluginId = constants.sourceId | |||||||||||||||||||||||||||||||||
* Plugin to validate that Markdown links and images reference existing local | ||||||||||||||||||||||||||||||||||
* files and headings. | ||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||
* @type {import('unified').Plugin<[Options?, FileSet?]|[Options?]|void[], Root>} | ||||||||||||||||||||||||||||||||||
* @typedef {import('unified-lint-rule').Label|import('unified-lint-rule').Severity} Severity | ||||||||||||||||||||||||||||||||||
* @type {import('unified').Plugin<[(Options|[Severity, Options?])?, FileSet?], Root>} | ||||||||||||||||||||||||||||||||||
* https://github.com/microsoft/TypeScript/pull/48132 | ||||||||||||||||||||||||||||||||||
* @param [rawOptions] | ||||||||||||||||||||||||||||||||||
* @param [fileSet] | ||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||
export default function remarkValidateLinks(options, fileSet) { | ||||||||||||||||||||||||||||||||||
export default function remarkValidateLinks(rawOptions, fileSet) { | ||||||||||||||||||||||||||||||||||
// Attach a `completer`. | ||||||||||||||||||||||||||||||||||
if (fileSet) { | ||||||||||||||||||||||||||||||||||
fileSet.use(cliCompleter) | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
// Find references and landmarks. | ||||||||||||||||||||||||||||||||||
return (tree, file, next) => { | ||||||||||||||||||||||||||||||||||
find.run( | ||||||||||||||||||||||||||||||||||
{tree, file, fileSet, options: {...options}}, | ||||||||||||||||||||||||||||||||||
/** @type {Callback} */ | ||||||||||||||||||||||||||||||||||
(error) => { | ||||||||||||||||||||||||||||||||||
if (error) { | ||||||||||||||||||||||||||||||||||
next(error) | ||||||||||||||||||||||||||||||||||
} else if (fileSet) { | ||||||||||||||||||||||||||||||||||
next() | ||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||
checkAll([file], next) | ||||||||||||||||||||||||||||||||||
return lintRule( | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
origin: 'validate-links', | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This most likely prevents remark-validate-links/lib/check/validate.js Lines 73 to 88 in 78871b0
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It’s likely not correct to use use |
||||||||||||||||||||||||||||||||||
url: 'https://github.com/remarkjs/remark-validate-links#readme' | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
/** @type {import('unified-lint-rule').Rule<Root, Options>} */ ( | ||||||||||||||||||||||||||||||||||
tree, | ||||||||||||||||||||||||||||||||||
file, | ||||||||||||||||||||||||||||||||||
options, | ||||||||||||||||||||||||||||||||||
next | ||||||||||||||||||||||||||||||||||
) => { | ||||||||||||||||||||||||||||||||||
find.run( | ||||||||||||||||||||||||||||||||||
{tree, file, fileSet, options: {...options}}, | ||||||||||||||||||||||||||||||||||
/** @type {Callback} */ | ||||||||||||||||||||||||||||||||||
(error) => { | ||||||||||||||||||||||||||||||||||
if (error) { | ||||||||||||||||||||||||||||||||||
next(error) | ||||||||||||||||||||||||||||||||||
} else if (fileSet) { | ||||||||||||||||||||||||||||||||||
next() | ||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||
checkAll([file], next) | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
).call(this, rawOptions) | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typedef
should not be in this block: that makes the description belong to it. The description belongs to the plugin. You can move the typedef up.