Skip to content

Commit

Permalink
Update unified, @types/mdast, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 9, 2023
1 parent 9a39d40 commit 255ca39
Show file tree
Hide file tree
Showing 114 changed files with 710 additions and 622 deletions.
9 changes: 8 additions & 1 deletion .remarkrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import remarkPresetLintRecommended from './packages/remark-preset-lint-recommended/index.js'
import remarkPresetLintConsistent from './packages/remark-preset-lint-consistent/index.js'
import remarkLintListItemIndent from './packages/remark-lint-list-item-indent/index.js'
import remarkToc from 'remark-toc'
import remarkCommentConfig from 'remark-comment-config'
import remarkGfm from 'remark-gfm'
Expand All @@ -11,6 +12,8 @@ import listOfRules from './script/plugin/list-of-rules.js'
const plugins = [
remarkPresetLintRecommended,
remarkPresetLintConsistent,
// To do: change.
[remarkLintListItemIndent, 'tab-size'],
[remarkToc, {tight: true, maxDepth: 3, heading: 'contents'}],
remarkCommentConfig,
[remarkGfm, {tablePipeAlign: false}],
Expand All @@ -20,6 +23,10 @@ const plugins = [
listOfRules
]

const preset = {plugins}
const preset = {
plugins,
// To do: change.
settings: {listItemIndent: 'tab'}
}

export default preset
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,29 +110,29 @@
"packages/unified-lint-rule"
],
"devDependencies": {
"@types/mdast": "^3.0.0",
"@types/mdast": "^4.0.0",
"@types/parse-author": "^2.0.0",
"@types/pluralize": "^0.0.33",
"c8": "^8.0.0",
"comment-parser": "^1.0.0",
"github-slugger": "^2.0.0",
"mdast-zone": "^5.0.0",
"mdast-zone": "^6.0.0",
"parse-author": "^2.0.0",
"prettier": "^3.0.0",
"remark": "^14.0.0",
"remark-cli": "^11.0.0",
"remark-comment-config": "^7.0.0",
"remark-gfm": "^3.0.0",
"remark-github": "^11.0.0",
"remark-toc": "^8.0.0",
"remark-validate-links": "^12.0.0",
"remark": "^15.0.0",
"remark-cli": "^12.0.0",
"remark-comment-config": "^8.0.0",
"remark-gfm": "^4.0.0",
"remark-github": "^12.0.0",
"remark-toc": "^9.0.0",
"remark-validate-links": "^13.0.0",
"strip-indent": "^4.0.0",
"to-vfile": "^7.0.0",
"to-vfile": "^8.0.0",
"type-coverage": "^2.0.0",
"type-fest": "^4.0.0",
"typescript": "^5.0.0",
"unist-builder": "^3.0.0",
"unist-util-remove-position": "^4.0.0",
"unist-builder": "^4.0.0",
"unist-util-remove-position": "^5.0.0",
"xo": "^0.56.0"
},
"scripts": {
Expand Down
45 changes: 22 additions & 23 deletions packages/remark-lint-blockquote-indentation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,35 +106,34 @@ const remarkLintBlockquoteIndentation = lintRule(
return
}

if (option === 'consistent') {
option = check(node)
} else {
const diff = option - check(node)
const start = pointStart(node)
const head = pointStart(node.children[0])
/* c8 ignore next -- we get here if we have offsets. */
const count = head && start ? head.column - start.column : undefined

if (diff !== 0) {
const abs = Math.abs(diff)
if (typeof count === 'number') {
if (option === 'consistent') {
option = count
} else {
const diff = option - count

file.message(
(diff > 0 ? 'Add' : 'Remove') +
' ' +
abs +
' ' +
plural('space', abs) +
' between block quote and content',
pointStart(node.children[0])
)
if (diff !== 0) {
const abs = Math.abs(diff)

file.message(
(diff > 0 ? 'Add' : 'Remove') +
' ' +
abs +
' ' +
plural('space', abs) +
' between block quote and content',
pointStart(node.children[0])
)
}
}
}
})
}
)

export default remarkLintBlockquoteIndentation

/**
* @param {Blockquote} node
* @returns {number}
*/
function check(node) {
return pointStart(node.children[0]).column - pointStart(node).column
}
10 changes: 5 additions & 5 deletions packages/remark-lint-blockquote-indentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"@types/mdast": "^4.0.0",
"pluralize": "^8.0.0",
"unified": "^10.0.0",
"unified": "^11.0.0",
"unified-lint-rule": "^2.0.0",
"unist-util-generated": "^2.0.0",
"unist-util-position": "^4.0.0",
"unist-util-visit": "^4.0.0"
"unist-util-generated": "^3.0.0",
"unist-util-position": "^5.0.0",
"unist-util-visit": "^5.0.0"
},
"scripts": {},
"xo": {
Expand Down
1 change: 1 addition & 0 deletions packages/remark-lint-checkbox-character-style/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const remarkLintCheckboxCharacterStyle = lintRule(
// Exit early for items without checkbox.
// A list item cannot be checked and empty, according to GFM.
if (
!point ||
typeof node.checked !== 'boolean' ||
!head ||
typeof point.offset !== 'number'
Expand Down
8 changes: 4 additions & 4 deletions packages/remark-lint-checkbox-character-style/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"unified": "^10.0.0",
"@types/mdast": "^4.0.0",
"unified": "^11.0.0",
"unified-lint-rule": "^2.0.0",
"unist-util-position": "^4.0.0",
"unist-util-visit": "^4.0.0"
"unist-util-position": "^5.0.0",
"unist-util-visit": "^5.0.0"
},
"scripts": {},
"xo": {
Expand Down
14 changes: 9 additions & 5 deletions packages/remark-lint-checkbox-content-indent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const remarkLintCheckboxContentIndent = lintRule(
// Exit early for items without checkbox.
// A list item cannot be checked and empty, according to GFM.
if (
!point ||
typeof node.checked !== 'boolean' ||
!head ||
typeof point.offset !== 'number'
Expand All @@ -110,11 +111,14 @@ const remarkLintCheckboxContentIndent = lintRule(
while (/[\t ]/.test(value.charAt(final))) final++

if (final - initial > 0) {
// @ts-expect-error: assume we have a correct point.
file.message('Checkboxes should be followed by a single character', {
start: loc.toPoint(initial),
end: loc.toPoint(final)
})
const start = loc.toPoint(initial)
const end = loc.toPoint(final)

file.message(
'Checkboxes should be followed by a single character',
/* c8 ignore next -- we get here if we have offsets. */
start && end ? {start, end} : undefined
)
}
})
}
Expand Down
10 changes: 5 additions & 5 deletions packages/remark-lint-checkbox-content-indent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"unified": "^10.0.0",
"@types/mdast": "^4.0.0",
"unified": "^11.0.0",
"unified-lint-rule": "^2.0.0",
"unist-util-position": "^4.0.0",
"unist-util-visit": "^4.0.0",
"vfile-location": "^4.0.0"
"unist-util-position": "^5.0.0",
"unist-util-visit": "^5.0.0",
"vfile-location": "^5.0.0"
},
"scripts": {},
"xo": {
Expand Down
17 changes: 11 additions & 6 deletions packages/remark-lint-code-block-style/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
import {lintRule} from 'unified-lint-rule'
import {visit} from 'unist-util-visit'
import {pointStart, pointEnd} from 'unist-util-position'
import {generated} from 'unist-util-generated'

const remarkLintCodeBlockStyle = lintRule(
{
Expand All @@ -164,15 +163,21 @@ const remarkLintCodeBlockStyle = lintRule(
}

visit(tree, 'code', (node) => {
if (generated(node)) {
const initial = pointStart(node)
const final = pointEnd(node)

if (
!initial ||
!final ||
typeof initial.offset !== 'number' ||
typeof final.offset !== 'number'
) {
return
}

const initial = pointStart(node).offset
const final = pointEnd(node).offset

const current =
node.lang || /^\s*([~`])\1{2,}/.test(value.slice(initial, final))
node.lang ||
/^\s*([~`])\1{2,}/.test(value.slice(initial.offset, final.offset))
? 'fenced'
: 'indented'

Expand Down
9 changes: 4 additions & 5 deletions packages/remark-lint-code-block-style/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"unified": "^10.0.0",
"@types/mdast": "^4.0.0",
"unified": "^11.0.0",
"unified-lint-rule": "^2.0.0",
"unist-util-generated": "^2.0.0",
"unist-util-position": "^4.0.0",
"unist-util-visit": "^4.0.0"
"unist-util-position": "^5.0.0",
"unist-util-visit": "^5.0.0"
},
"scripts": {},
"xo": {
Expand Down
13 changes: 9 additions & 4 deletions packages/remark-lint-definition-case/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,16 @@ const remarkLintDefinitionCase = lintRule(

visit(tree, (node) => {
if (node.type === 'definition' || node.type === 'footnoteDefinition') {
const start = pointStart(node).offset
const end = pointEnd(node).offset
const start = pointStart(node)
const end = pointEnd(node)

if (typeof start === 'number' && typeof end === 'number') {
const match = value.slice(start, end).match(label)
if (
start &&
end &&
typeof start.offset === 'number' &&
typeof end.offset === 'number'
) {
const match = value.slice(start.offset, end.offset).match(label)

if (match && match[1] !== match[1].toLowerCase()) {
file.message(
Expand Down
8 changes: 4 additions & 4 deletions packages/remark-lint-definition-case/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"unified": "^10.0.0",
"@types/mdast": "^4.0.0",
"unified": "^11.0.0",
"unified-lint-rule": "^2.0.0",
"unist-util-position": "^4.0.0",
"unist-util-visit": "^4.0.0"
"unist-util-position": "^5.0.0",
"unist-util-visit": "^5.0.0"
},
"scripts": {},
"xo": {
Expand Down
13 changes: 9 additions & 4 deletions packages/remark-lint-definition-spacing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,16 @@ const remarkLintDefinitionSpacing = lintRule(

visit(tree, (node) => {
if (node.type === 'definition' || node.type === 'footnoteDefinition') {
const start = pointStart(node).offset
const end = pointEnd(node).offset
const start = pointStart(node)
const end = pointEnd(node)

if (typeof start === 'number' && typeof end === 'number') {
const match = value.slice(start, end).match(label)
if (
start &&
end &&
typeof start.offset === 'number' &&
typeof end.offset === 'number'
) {
const match = value.slice(start.offset, end.offset).match(label)

if (match && /[ \t\n]{2,}/.test(match[1])) {
file.message(
Expand Down
8 changes: 4 additions & 4 deletions packages/remark-lint-definition-spacing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"unified": "^10.0.0",
"@types/mdast": "^4.0.0",
"unified": "^11.0.0",
"unified-lint-rule": "^2.0.0",
"unist-util-position": "^4.0.0",
"unist-util-visit": "^4.0.0"
"unist-util-position": "^5.0.0",
"unist-util-visit": "^5.0.0"
},
"scripts": {},
"xo": {
Expand Down
6 changes: 3 additions & 3 deletions packages/remark-lint-emphasis-marker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ const remarkLintEmphasisMarker = lintRule(
}

visit(tree, 'emphasis', (node) => {
const start = pointStart(node).offset
const start = pointStart(node)

if (typeof start === 'number') {
const marker = /** @type {Marker} */ (value.charAt(start))
if (start && typeof start.offset === 'number') {
const marker = /** @type {Marker} */ (value.charAt(start.offset))

if (option === 'consistent') {
option = marker
Expand Down
8 changes: 4 additions & 4 deletions packages/remark-lint-emphasis-marker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"unified": "^10.0.0",
"@types/mdast": "^4.0.0",
"unified": "^11.0.0",
"unified-lint-rule": "^2.0.0",
"unist-util-position": "^4.0.0",
"unist-util-visit": "^4.0.0"
"unist-util-position": "^5.0.0",
"unist-util-visit": "^5.0.0"
},
"scripts": {},
"xo": {
Expand Down
Loading

0 comments on commit 255ca39

Please sign in to comment.