Skip to content

Commit 508e7ce

Browse files
JounQinjaswrks
andauthored
feat!: bump all unified ecosystem dependencies, support mdx v3 (#486)
Co-authored-by: Jason Caldwell <[email protected]>
1 parent 7ca1ffe commit 508e7ce

26 files changed

+3937
-6050
lines changed

.changeset/spicy-bikes-sparkle.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"eslint-mdx": major
3+
"eslint-plugin-mdx": major
4+
---
5+
6+
feat!: bump all unified ecosystem dependencies, support mdx v3

.changeset/swift-cycles-mix.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"eslint-mdx": major
3+
"eslint-plugin-mdx": major
4+
---
5+
6+
chore!: require node >= 18, drop node 12, 14 and 16

.codesandbox/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"node": "16",
2+
"node": "18",
33
"packages": [
44
"packages/*"
55
],

.github/workflows/ci.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ jobs:
1414
- ubuntu-latest
1515
- windows-latest
1616
node:
17-
- 16
1817
- 18
1918
- 20
2019
runs-on: ${{ matrix.os }}
2120
steps:
2221
- name: Checkout Repo
23-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2423

2524
- name: Setup Node.js ${{ matrix.node }}
26-
uses: actions/setup-node@v3
25+
uses: actions/setup-node@v4
2726
with:
2827
node-version: ${{ matrix.node }}
2928
cache: yarn

.github/workflows/codeql.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
steps:
2626
- name: Checkout
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2828

2929
- name: Initialize CodeQL
3030
uses: github/codeql-action/init@v2

.github/workflows/pkg-size.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212

1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1616

17-
- name: Setup Node.js
18-
uses: actions/setup-node@v3
17+
- name: Setup Node.js LTS
18+
uses: actions/setup-node@v4
1919
with:
20-
node-version: 16
20+
node-version: lts/*
2121
cache: yarn
2222

2323
- name: Package Size Report

.github/workflows/release.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout Repo
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515
with:
1616
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
1717
fetch-depth: 0
1818

19-
- name: Setup Node.js 16
20-
uses: actions/setup-node@v3
19+
- name: Setup Node.js LTS
20+
uses: actions/setup-node@v4
2121
with:
22-
node-version: 16
22+
node-version: lts/*
2323
cache: yarn
2424

2525
- name: Install Dependencies

package.json

+22-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"workspaces": [
1010
"packages/*"
1111
],
12-
"packageManager": "[email protected].19",
12+
"packageManager": "[email protected].21",
1313
"scripts": {
1414
"build": "run-p build:*",
1515
"build:r": "r -f es2015",
@@ -27,25 +27,34 @@
2727
},
2828
"devDependencies": {
2929
"@1stg/lib-config": "^12.0.0",
30-
"@changesets/changelog-github": "^0.4.8",
31-
"@changesets/cli": "^2.26.2",
32-
"@types/eslint": "^8.44.1",
33-
"@types/eslint-plugin-markdown": "^2.0.0",
34-
"@types/jest": "^29.5.3",
35-
"@types/node": "^20.4.6",
36-
"@types/react": "^18.2.18",
37-
"@types/unist": "^2.0.6",
38-
"jest": "^29.6.2",
30+
"@changesets/changelog-github": "^0.5.0",
31+
"@changesets/cli": "^2.27.1",
32+
"@types/eslint": "^8.44.8",
33+
"@types/eslint-plugin-markdown": "^2.0.2",
34+
"@types/jest": "^29.5.10",
35+
"@types/node": "^20.10.3",
36+
"@types/react": "^18.2.42",
37+
"@types/unist": "^3.0.2",
38+
"jest": "^29.7.0",
3939
"patch-package": "^8.0.0",
4040
"react": "^18.2.0",
4141
"ts-jest": "^29.1.1",
4242
"ts-node": "^10.9.1",
43-
"type-coverage": "^2.26.0",
44-
"typescript": "^5.1.6",
43+
"type-coverage": "^2.27.0",
44+
"typescript": "^5.3.2",
4545
"yarn-deduplicate": "^6.0.2"
4646
},
4747
"resolutions": {
48-
"prettier": "^2.8.8"
48+
"@types/acorn": "^6.0.0",
49+
"@types/mdast": "^4.0.3",
50+
"acorn": "^8.11.2",
51+
"cliui": "npm:@isaacs/cliui@^8.0.2",
52+
"eslint-plugin-markdown": "JounQin/eslint-plugin-markdown#feat/bump",
53+
"mdast-util-frontmatter": "^2.0.1",
54+
"mdast-util-gfm": "^3.0.0",
55+
"prettier": "^2.8.8",
56+
"unified": "^11.0.4",
57+
"unified-engine": "^11.2.0"
4958
},
5059
"commitlint": {
5160
"extends": [

packages/eslint-mdx/package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"license": "MIT",
1313
"engines": {
14-
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
14+
"node": ">=18.0.0"
1515
},
1616
"main": "lib/index.js",
1717
"module": "lib/index.es2015.mjs",
@@ -30,19 +30,19 @@
3030
"eslint": ">=8.0.0"
3131
},
3232
"dependencies": {
33-
"acorn": "^8.10.0",
33+
"acorn": "^8.11.2",
3434
"acorn-jsx": "^5.3.2",
3535
"espree": "^9.6.1",
36-
"estree-util-visit": "^1.2.1",
37-
"remark-mdx": "^2.3.0",
38-
"remark-parse": "^10.0.2",
39-
"remark-stringify": "^10.0.3",
40-
"synckit": "^0.8.5",
41-
"tslib": "^2.6.1",
42-
"unified": "^10.1.2",
43-
"unified-engine": "^10.1.0",
44-
"unist-util-visit": "^4.1.2",
36+
"estree-util-visit": "^2.0.0",
37+
"remark-mdx": "^3.0.0",
38+
"remark-parse": "^11.0.0",
39+
"remark-stringify": "^11.0.0",
40+
"synckit": "^0.8.6",
41+
"tslib": "^2.6.2",
42+
"unified": "^11.0.4",
43+
"unified-engine": "^11.2.0",
44+
"unist-util-visit": "^5.0.0",
4545
"uvu": "^0.5.6",
46-
"vfile": "^5.3.7"
46+
"vfile": "^6.0.1"
4747
}
4848
}

packages/eslint-mdx/src/helpers.ts

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ export const getPositionAtFactory = (text: string) => {
7777
return {
7878
line,
7979
column: offset - currOffset,
80-
offset,
8180
}
8281
}
8382

packages/eslint-mdx/src/parser.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ export class Parser {
6262
ignoreRemarkConfig,
6363
})
6464
} catch (err: unknown) {
65-
const error = err as VFileMessage
66-
throw Object.assign(new SyntaxError(error.message), {
67-
lineNumber: error.line,
68-
column: error.column,
69-
index: /* istanbul ignore next */ error.position?.start.offset,
65+
const { message, line, column, place } = err as VFileMessage
66+
const point = place && ('start' in place ? place.start : place)
67+
throw Object.assign(new SyntaxError(message), {
68+
lineNumber: line,
69+
column,
70+
index: /* istanbul ignore next */ point?.offset,
7071
})
7172
}
7273

packages/eslint-mdx/src/tokens.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
/// <reference types="remark-mdx" />
2+
13
import type { Token, TokenType, tokTypes } from 'acorn'
2-
import type { Root } from 'remark-mdx'
4+
import type { Root } from 'mdast'
35
import type { visit as visitor } from 'unist-util-visit'
46
import { ok as assert } from 'uvu/assert'
57

@@ -29,6 +31,7 @@ export const restoreTokens = (
2931
value?: string,
3032
): Token => ({
3133
type,
34+
// @ts-expect-error -- FIXME: `value` is a valid property of `Token`
3235
value,
3336
start,
3437
end,

packages/eslint-mdx/src/worker.ts

+19-14
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ import type {
2525
} from 'estree-jsx'
2626
import type {
2727
BlockContent,
28-
PhrasingContent,
2928
Literal as MdastLiteral,
29+
PhrasingContent,
30+
Root,
3031
} from 'mdast'
3132
import type { Options } from 'micromark-extension-mdx-expression'
32-
import type { Root } from 'remark-mdx'
3333
import { extractProperties, runAsWorker } from 'synckit'
34-
import type { FrozenProcessor } from 'unified'
35-
import type { Config, Configuration } from 'unified-engine/lib/configuration'
34+
import type { Processor } from 'unified'
35+
import type { Configuration, ConfigResult } from 'unified-engine'
3636
import type { Node } from 'unist'
3737
import { ok as assert } from 'uvu/assert'
3838
import type { VFileMessage } from 'vfile-message'
@@ -60,13 +60,16 @@ let tt: Record<string, TokenType> & typeof _tokTypes
6060

6161
let TokenTranslator: typeof import('espree/lib/token-translator')['default']
6262

63-
export const processorCache = new Map<string, FrozenProcessor>()
63+
export const processorCache = new Map<
64+
string,
65+
Processor<Root, undefined, undefined, Root, string>
66+
>()
6467

6568
const getRemarkConfig = async (searchFrom: string) => {
6669
if (!config) {
6770
const { Configuration } = await loadEsmModule<
68-
typeof import('unified-engine/lib/configuration')
69-
>('unified-engine/lib/configuration.js')
71+
typeof import('unified-engine')
72+
>('unified-engine')
7073
config = new Configuration({
7174
cwd: process.cwd(),
7275
packageField: 'remarkConfig',
@@ -76,10 +79,10 @@ const getRemarkConfig = async (searchFrom: string) => {
7679
})
7780
}
7881

79-
return new Promise<Config>((resolve, reject) =>
80-
config.load(searchFrom, (error, result) =>
81-
error ? reject(error) : resolve(result),
82-
),
82+
return new Promise<ConfigResult>((resolve, reject) =>
83+
config.load(searchFrom, (error, result) => {
84+
error ? reject(error) : resolve(result)
85+
}),
8386
)
8487
}
8588

@@ -270,7 +273,7 @@ runAsWorker(
270273
const text = fileOptions.value as string
271274
const tokenTranslator = new TokenTranslator(tt, text)
272275

273-
const root = processor.parse(fileOptions) as Root
276+
const root = processor.parse(fileOptions)
274277

275278
const body: Program['body'] = []
276279
const comments: Comment[] = []
@@ -372,7 +375,7 @@ runAsWorker(
372375
processed.add(child)
373376

374377
if (child.data && 'estree' in child.data && child.data.estree) {
375-
const estree = child.data.estree as Program
378+
const { estree } = child.data
376379

377380
assert(estree.body.length <= 1)
378381

@@ -638,7 +641,9 @@ runAsWorker(
638641
})
639642
}
640643

641-
const estree = (node.data?.estree || {
644+
const estree = ((node.data &&
645+
'estree' in node.data &&
646+
node.data.estree) || {
642647
body: [],
643648
comments: [],
644649
}) as Program

packages/eslint-plugin-mdx/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"license": "MIT",
1313
"engines": {
14-
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
14+
"node": ">=18.0.0"
1515
},
1616
"main": "lib/index.js",
1717
"module": "lib/index.es2015.mjs",
@@ -33,11 +33,11 @@
3333
"dependencies": {
3434
"eslint-mdx": "^2.2.0",
3535
"eslint-plugin-markdown": "^3.0.1",
36-
"remark-mdx": "^2.3.0",
37-
"remark-parse": "^10.0.2",
38-
"remark-stringify": "^10.0.3",
39-
"tslib": "^2.6.1",
40-
"unified": "^10.1.2",
41-
"vfile": "^5.3.7"
36+
"remark-mdx": "^3.0.0",
37+
"remark-parse": "^11.0.0",
38+
"remark-stringify": "^11.0.0",
39+
"tslib": "^2.6.2",
40+
"unified": "^11.0.4",
41+
"vfile": "^6.0.1"
4242
}
4343
}

packages/eslint-plugin-mdx/src/processors/remark.ts

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { processorOptions as defaultProcessorOptions } from './options'
1010
export const createRemarkProcessor = (
1111
processorOptions = defaultProcessorOptions,
1212
): Linter.Processor => ({
13-
// @ts-expect-error -- FIXME: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65826
1413
meta: {
1514
name: 'mdx/remark',
1615
version: meta.version,

packages/eslint-plugin-mdx/src/rules/remark.ts

+16-14
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const remark: Rule.RuleModule = {
7272
fatal,
7373
line,
7474
column,
75-
position: { start, end },
75+
place,
7676
} of messages) {
7777
// https://github.com/remarkjs/remark-lint/issues/65#issuecomment-220800231
7878
/* istanbul ignore next */
@@ -89,22 +89,24 @@ export const remark: Rule.RuleModule = {
8989
ruleId,
9090
severity,
9191
}
92+
93+
const point = {
94+
line,
95+
// ! eslint ast column is 0-indexed, but unified is 1-indexed
96+
column: column - 1,
97+
}
98+
9299
context.report({
93100
// related to https://github.com/eslint/eslint/issues/14198
94101
message: JSON.stringify(message),
95-
loc: {
96-
line,
97-
// ! eslint ast column is 0-indexed, but unified is 1-indexed
98-
column: column - 1,
99-
start: {
100-
...start,
101-
column: start.column - 1,
102-
},
103-
end: {
104-
...end,
105-
column: end.column - 1,
106-
},
107-
},
102+
loc:
103+
/* istanbul ignore next */ 'start' in place
104+
? {
105+
...point,
106+
start: { ...place.start, column: place.start.column - 1 },
107+
end: { ...place.end, column: place.end.column - 1 },
108+
}
109+
: point,
108110
node,
109111
fix:
110112
fixedText === sourceText

0 commit comments

Comments
 (0)