Refactor to use more default arguments

This commit is contained in:
Titus Wormer 2021-08-12 14:08:47 +02:00
parent ef896866cf
commit 16c1b6fd16
No known key found for this signature in database
GPG Key ID: E6E581152ED04E2E
3 changed files with 6 additions and 9 deletions

View File

@ -36,12 +36,11 @@ import {lintRule} from 'unified-lint-rule'
const remarkLintFileExtension = lintRule(
'remark-lint:file-extension',
/** @type {import('unified-lint-rule').Rule<Root, Options>} */
(_, file, option) => {
(_, file, option = 'md') => {
const ext = file.extname
const preferred = typeof option === 'string' ? option : 'md'
if (ext && ext.slice(1) !== preferred) {
file.message('Incorrect extension: use `' + preferred + '`')
if (ext && ext.slice(1) !== option) {
file.message('Incorrect extension: use `' + option + '`')
}
}
)

View File

@ -16,7 +16,6 @@ Warn when table rows are not fenced with pipes.
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
creates fenced rows with initial and final pipes by default.
Pass
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
on how to automatically fix warnings for this rule.

View File

@ -30,12 +30,11 @@ import {lintRule} from 'unified-lint-rule'
const remarkLintFileExtension = lintRule(
'remark-lint:file-extension',
(tree, file, option) => {
(tree, file, option = 'md') => {
var ext = file.extname
var preferred = typeof option === 'string' ? option : 'md'
if (ext && ext.slice(1) !== preferred) {
file.message('Incorrect extension: use `' + preferred + '`')
if (ext && ext.slice(1) !== option) {
file.message('Incorrect extension: use `' + option + '`')
}
}
)