mirror of
https://github.com/remarkjs/remark-lint.git
synced 2024-09-11 19:57:15 +03:00
Refactor to use more default arguments
This commit is contained in:
parent
ef896866cf
commit
16c1b6fd16
@ -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 + '`')
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -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.
|
||||
|
@ -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 + '`')
|
||||
}
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user