Skip to content

Commit

Permalink
Refactor to use more default arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 12, 2021
1 parent ef89686 commit 16c1b6f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 3 additions & 4 deletions packages/remark-lint-file-extension/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '`')
}
}
)
Expand Down
1 change: 0 additions & 1 deletion packages/remark-lint-table-pipes/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 3 additions & 4 deletions packages/unified-lint-rule/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '`')
}
}
)
Expand Down

0 comments on commit 16c1b6f

Please sign in to comment.